#include "plane.h"
#include "vector/vec.h"

#include <stddef.h>
#include <stdlib.h>


Plane * plane_create(float width, float height, float friction) {
	Plane * p = NULL;
	Droplet * droplets = NULL;
	
	p = malloc(sizeof(*p));
	if (p == NULL) {
		goto error;
	}
	droplets = vector_create();
	if (droplets == NULL) {
		goto error;
	}
	p->width = width;
	p->height = height;
	p->friction = friction;
	p->droplets = droplets;
	return p;
	
	error:
	plane_free(p);
	return NULL;
}


void plane_free(Plane * p) {
	if (p != NULL) {
		vector_free(p->droplets);
		free(p);
		p = NULL;
	}
}
